
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>超市账单管理系统</title>
    <link rel="stylesheet" href="/statics/css/public.css"/>
    <link rel="stylesheet" href="/statics/css/style.css"/>
    <script type="text/javascript" src="/statics/js/jquery.js"></script>
    <script type="text/javascript">
        $(function () {
            $("#oldPassword").blur(function () {
               var oldPassword=$(this).val();
                $.get("/sys/user/checkPassword", "oldPassword=" + oldPassword, function (result) {
                    if(result=='success'){
                        //验证通过
                        $("#oldPassword").next().html("√");
                    }else if(result=="error"){
                        //密码输入错误
                        $("#oldPassword").next().html("旧码输入错误");
                        $("#oldPassword").focus();
                    }else{
                        //登录超时
                        alert("登录超时，请重新登录");
                        location.href = "/user/toLogin";
                    }
                });
            });
            //修改密码
            $("input[type='button']").click(function () {
                //验证新密码
                var userPassword = $("#userPassword").val();
                if(userPassword.length<6 || userPassword.length>12){
                    //密码格式不正确
                    $("#userPassword").next().html("密码格式不正确");
                    return;
                }else {
                    $("#userPassword").next().html("√");
                }
                //验证重复密码
                var rePassword = $("#rePassword").val();
                if (rePassword == userPassword){
                    $("#rePassword").next().html("√");
                }else{
                    $("#rePassword").next().html("两次密码输入不一致");
                    return;
                }
                //密码修改
                $.post("/sys/user/updatePassword","userPassword="+userPassword,function (result) {
                    if(result=='success'){
                        //到登录页面
                        alert("修改密码成功，请重新登录");
                        window.open("/toLogin");
                    }else {
                        alert("修改密码失败");
                    }
                });
            })
        });
    </script>
</head>
<body>
<section class="publicMian ">
    <div class="right">
        <div class="location">
            <strong>你现在所在的位置是:</strong>
            <span>用户管理页面 >> 用户修改页面</span>
        </div>
        <div class="providerAdd">
            <form action="#">
                <!--div的class 为error是验证错误，ok是验证成功-->
                <div>
                    <label for="oldPassword">旧密码：</label>
                    <input type="password" name="oldPassword" id="oldPassword"/>
                    <span >*</span>
                </div>

                <div>
                    <label for="userPassword" >新密码：</label>

                    <input type="password" name="userPassword" id="userPassword"/>
                    <span >*</span>
                </div>
                <div>
                    <label for="rePassword">重复密码：</label>
                    <input type="password" name="rePassword" id="rePassword" />
                    <span >*</span>
                </div>


                <div class="providerAddBtn">
                    <!--<a href="#">保存</a>-->
                    <!--<a href="userList.html">返回</a>-->
                    <input type="button" value="保存"/>

                </div>
            </form>
        </div>

    </div>
</section>
</body>
</html>
